package com.tourism.controller;

import com.github.pagehelper.PageInfo;
import com.tourism.entity.AttractionEvaluation;
import com.tourism.entity.AttractionEvaluationQuery;
import com.tourism.exception.GlobalException;
import com.tourism.service.AttractionEvaluationService;
import com.tourism.util.common.Response;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

/**
 * @Description景点评价相关的控制器
 * @Author z
 * @Date 2021-03-01 20:40
 */
@Controller
@RequestMapping("/attractionEvaluation")
public class AttractionEvaluationController {


    @Autowired
    private AttractionEvaluationService attractionEvaluationService;

    /**
     * 根据景点id查询景点信息
     *
     * @param id
     * @return
     */
    @GetMapping("/getAttractionEvaluationById")
    @ResponseBody
    public AttractionEvaluation getAttractionEvaluationById(Long id) {
        return attractionEvaluationService.getAttractionEvaluationById(id);
    }

    /**
     * 根据景点订单id查询景点信息
     *
     * @param orderId
     * @return
     */
    @GetMapping("/getAttractionEvaluationByOrderId")
    @ResponseBody
    public AttractionEvaluation getAttractionEvaluationByOrderId(Long orderId) {
        return attractionEvaluationService.getAttractionEvaluationByOrderId(orderId);
    }


    /**
     * 新增景点评价
     *
     * @param attractionEvaluation
     * @return
     */
    @PostMapping("/addAttractionEvaluation")
    @ResponseBody
    public Response addAttractionEvaluation(@RequestBody AttractionEvaluation attractionEvaluation) throws GlobalException {
        return Response.success(attractionEvaluationService.addAttractionEvaluation(attractionEvaluation));

    }


    /**
     * 查询景点评价列表
     *
     * @param attractionEvaluationQuery
     * @return
     */
    @PostMapping("/getAttractionEvaluationList")
    @ResponseBody
    public PageInfo<AttractionEvaluation> getAttractionEvaluationList(@RequestBody AttractionEvaluationQuery attractionEvaluationQuery) {
        return attractionEvaluationService.getAttractionEvaluationList(attractionEvaluationQuery);
    }

}
